# 1、处理一个异常
try:
    file = open('test.txt', 'rb')
except IOError as e:
    print('【1】An IOError occurred. {}'.format(e.args[-1]))

# 2、处理多个异常
# 把所有可能发生的异常放到一个元组里
try:
    file1 = open('test.txt', 'rb')
except (IOError, EOFError) as e:
    print("【2】An error occurred. {}".format(e.args[-1]))

# 3、对每个单独的异常在单独的except语句块中处理
try:
    file = open('test.txt', 'rb')
except EOFError as e:
    print("【3】An EOFError  occurred ")
    raise e  # 打印一些异常日志
except IOError as e:
    print("【3】An IOError occurred ")
    raise e
